<# while ($true) {
    $randomNumber = Get-Random -Minimum 1 -Maximum 101
    $userInput = Read-Host "Guess a number between 1 and 100 (or type 'exit' to quit)"

    if ($userInput -eq 'exit') {
        break
    }

    $lastGuessMaxNum = 100
    $lastGuessMinNum = 1 
    $lastGuessNumber = 0

    while ($userInput -ne $randomNumber) {
        
        if ($userInput -gt $randomNumber) {
            $lastGuessMaxNum = $userInput
            $lastGuessNumber = $userInput


            $guessStr = "Your guess is too high. Try a number between " + $lastGuessMinNum + " and " + $lastGuessNumber
            Write-Host $guessStr
        }elseif ($userInput -lt $randomNumber) {
            $lastGuessMaxNum = $userInput    

            $lastGuessNumber = [int]$lastGuessNumber
            $lastGuessNumber = $userInput
        

            $guessStr = "Your guess is too low. Try a number between " + $lastGuessNumber + " and " + "$lastGuessMaxNum"
            Write-Host $guessStr
        }
        $userInput = Read-Host "Please enter your next guess (or type 'exit' to quit)"
    }

    Write-Host "congratulations! You've guessed the correct number:" $randomNumber
    
}
#>

$randomNumber = Get-Random -Minimum 1 -Maximum 101

$userInput = Read-Host "Guess a number between 1 and 100 (or type 'exit' to quit)"



while ($userInput -ne $randomNumber) {
    
    if ($userInput -gt $randomNumber) {
        Write-Host "Your guess is too high. Try again."
    }elseif ($userInput -lt $randomNumber) {
        Write-Host "Your guess is too low. Try again."
    }

    $userInput = Read-Host "Please enter your next guess (or type 'exit' to quit)"
    if ($userInput -eq 'exit') {
        break
    }
    
}

Write-Host "congratulations! You've guessed the correct number:" $randomNumber











